package com.fosu.dao;

import com.fosu.domain.Role;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色持久层
 *
 * @author 郭俊求
 * @date 2020/11/9
 */
@Mapper
@Repository
public interface RoleDao {
    /**
     * 查找所有角色
     *
     * @return List<Role> 角色对象集合
     */
    @Select("select * from role")
    @Results(id = "roleMap", value = {
            @Result(id = true, property = "roleId", column = "role_id"),
            @Result(property = "roleName", column = "role_name"),
    })
    List<Role> findAll();



    /**
     * 根据角色id查询角色表中的角色
     *
     * @return List<Role> 角色对象集合
     */

    @Select("select role_name from role where role_id = #{roleId}")
    @Results({
            @Result(property = "roleName", column = "role_name")
    })
    String findRoleNameByRoleId(int roleId);
}
